package io.renren.modules.manage.controller;

import io.renren.modules.manage.entity.DataRestoreEntity;
import io.renren.modules.manage.service.DataRestoreService;
import io.renren.modules.manage.service.PayLogCopyService;
import io.renren.modules.seller.entity.PageResult;
import io.renren.modules.seller.entity.Result;
import io.renren.modules.seller.service.PayLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 数据备份记录日志
 *
 * @author 15373178086@163.com
 * @date 2020-02-21 12:05:42
 */
@Slf4j
@RestController
@RequestMapping("manage/restore")
public class DataRestoreController {
    @Autowired
    private DataRestoreService dataRestoreService;
    @Autowired
    private PayLogCopyService payLogCopyService;
    @Autowired
    private PayLogService payLogService;

    @RequestMapping(value = "copy")
    public Result copy() {
        dataRestoreService.copy();
        return Result.success();
    }

    @RequestMapping(value = "restored")
    public Result restore(Long id) {
        log.info("data restore id [{}]", id);
        dataRestoreService.restore(id);
        return Result.success();
    }

    /**
     * 返回全部列表
     *
     * @return TbBrands
     */
    @RequestMapping("/findAll")
    public List<DataRestoreEntity> findAll() {
        return dataRestoreService.list();
    }

    /**
     * 查询+分页
     *
     * @return PageResult
     */
    @RequestMapping("/search")
    public PageResult search(@RequestBody DataRestoreEntity dataRestoreEntity, String page, String limit) {
        return dataRestoreService.findPage(dataRestoreEntity, page, limit);
    }

    /**
     * 返回全部列表
     *
     * @return PageResult
     */
    @RequestMapping("/findPage")
    public PageResult findPage(@RequestParam Map<String, Object> params) {
        log.info("restore findPage params:{}", params);
        return dataRestoreService.findPage(params);
    }
}
